<template>
  <div>
    {{ obj.name }}
    {{ obj.arr }}
    <van-button type="primary" size="small" @click="changeData">方式一(修改)</van-button>
    <van-button type="primary" size="small" @click="changeDataC">方式二(修改)</van-button>
  </div>
</template>

<script>
import {
  reactive
} from 'vue';
export default {
  name: "reactive",
  setup() {
    let obj = reactive({
      name: "张三",
      arr: []
    });

    const changeData = () => { // 方式一
      obj.name = "ZS";
      obj.arr.push("1", "2");
    }
  
    return {
      obj,
      changeData
    }
  },
  methods: {
    changeDataC() {  // 方式二
      this.obj.name = "ZSC"
      this.obj.arr.push("3");
    }
  }
}
</script>